<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><{$tt}></title>
<link href="<{$smarty.const.BASEPATH}>/css/base.css" rel="stylesheet"/>
<link href="<{$smarty.const.BASEPATH}>/css/admin_style.css" rel="stylesheet"/>
<link href="<{$smarty.const.BASEPATH}>/css/css.css" type="text/css" rel="stylesheet" />
<link href="<{$smarty.const.BASEPATH}>/css/validform.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/pinyin.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/jquery.min.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/validform/js/Validform.min.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>xheditor/xheditor-zh-cn.min.js"></script>

<script type="text/javascript">
$(pageInit);
function pageInit()
{
	$.extend(xheditor.settings,{skin:'nostyle',shortcuts:{'ctrl+enter':submitForm}});//修改默认设置
	$('#content').xheditor({forcePtag:false,urlType:'rel',upLinkUrl:"<{spUrl c=upload a=file immediate=1}>",upLinkExt:"zip,rar,txt,word,xls,pdt",upImgUrl:"<{spUrl c=upload a=file immediate=1}>",upImgExt:"jpg,jpeg,gif,png,bmp",upFlashUrl:"<{spUrl c=upload a=file immediate=1}>",upFlashExt:"swf",upMediaUrl:"<{spUrl c=upload a=file immediate=1}>",upMediaExt:"wmv,avi,wma,mp3,mid",onUpload:insertUpload});
    $('#upimg').xheditor({skin:'upfile',tools:'Img',urlType:'root',upImgUrl:"!{editorRoot}xheditor_plugins/multiupload/multiupload.html?uploadurl=<{spUrl c=upload a=file immediate=1}>|",onUpload:insertUpload});
}
function insertUpload(arrMsg)
{
	var i,msg;
	for(i=0;i<arrMsg.length;i++)
	{
		msg=arrMsg[i];
		$("#uploadList").append('<option value="'+msg.newFilename+'">'+msg.newFilename+'</option>');
	    //$("#imglist").append('<img src="\/upload\/'+msg.newFilename+'" width=100>');
        //document.getElementById('allimg').value=document.getElementById('allimg').value+''+msg.newFilename;
        if($("#allimg").val()==""){
        $("#allimg").val($("#allimg").val()+msg.newFilename);
        }else{
        $("#allimg").val($("#allimg").val()+'|'+msg.newFilename);
        }
    }
}
function insertUpload2(file)
{
	$("#uploadList").append('<option value="'+file+'" selected="selected">'+file+'</option>');
        if($("#allimgx").val()==""){
        $("#allimg").val($("#allimg").val()+file);
        }else{
        $("#allimg").val($("#allimg").val()+'|'+file);
        }
}
function submitForm(){$('#frmDemo').submit();}

function TS()
{
 var ts =$('#title').val();
            $('#name').val(ts);
}
function ZH()
{
 var teststr =ConvertPinyin($('#name').val());
            teststr = teststr.replace(/[^A-z0-9]/g,"-");
            teststr = teststr.replace(/[_*&^]/g,"-");
            teststr = teststr.replace(/--/g,"-");
            teststr = teststr.replace(/-$/g,"");
            //alert(teststr);
          $('#alias').val(teststr);
}
</script>

<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>
<script type="text/javascript" src="<{$smarty.const.WEBDIR}>js/fancybox/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<{$smarty.const.WEBDIR}>js/fancybox/jquery.fancybox.css" media="screen" />


<script type="text/javascript">
		$(function() {
           $(".select_Relate").click(
                          function(){   
                              var news_Relate=$('#news_Relate').val();
                    		      $.fancybox({
                    		                'type':'iframe',
                    		                href : '<{spUrl c=products a=select_Relate type=news}>&news_Relate=' + news_Relate,
                                            title : '关联商品编辑框',
                                            maxWidth	: 720,
                                    		maxHeight	: 600,
                                    		fitToView	: true,
                                    		width		: '70%',
                                    		height		: '70%',
                                            autoSize	: true
                                  });
                                  });
			
		});
</script>

</head>

<body>

<script type="text/javascript">
$(function(){ // 当页面加载完毕的时候
$(".registerform:last").Validform({
		tiptype:2,
		ajaxPost:true,
		callback:function(data){
			//返回数据data是json格式，{"info":"demo info","status":"y"}
			//info: 输出提示信息;
			//status: 返回提交数据的状态,是否提交成功。如可以用"y"表示提交成功，"n"表示提交失败，在ajax_post.php文件返回数据里自定字符，主要用在callback函数里根据该值执行相应的回调操作;
			//你也可以在ajax_post.php文件返回更多信息在这里获取，进行相应操作；
			
			//这里执行回调操作;
			if(data.status=="y"){
				setTimeout(function(){
					$.Hidemsg(); //公用方法关闭信息提示框;
                    location.href="<{spUrl c=news a=index categories_id=$parent_id}>";
				},2000);
                //
			}
		} 
	});
});
</script>
   <form class="registerform" action="<{spUrl c=news a=save}>"> 
   <table class="tab_list tab_bottom">
   <caption><a href="#">◆<{$addtitle}></a></caption>
   <tr>
   <td width="50">*分类：</td>
   <td width="320"><select name="parent_id" id="parent_id" datatype="select" errormsg="请选择所属分类！">
<option value="">请选择所属分类</option>
<{function name=menu level=0}> 
<{for $i=0 to $i<$level*2-1}>    
<{$str=$str|cat:'　'}>
<{/for}>
<{if $level++}>
<{$str2= $str|cat:'├'}>
<{/if}>
<{foreach $data as $entry}> 
<option value='<{$entry.categories_id}>' <{if $entry.categories_id==$parent_id}>selected='selected'<{/if}><{if isset($entry.child)}>disabled="disabled"<{/if}>><{$str2}><{$entry.detail.categories_name}></option>
<{if isset($entry.child)}>             
<{call name=menu data=$entry.child level=$level}>           
<{/if}> 
<{/foreach}>  
<{/function}> 

<{call name=menu data=$arr}> 
</select></td><td><div class="Validform_checktip">分类必须选择!</div></td></tr>
        <tr>
            <td width="80">*网页标题：</td>
            <td width="320"><input type="text" value="<{$news.detail.news_title}>" id="title" name="title" class="inputxt"  datatype="*" nullmsg="请输入标题！"  /> <input type="checkbox" name="type" value="1" <{if $news.type==1}>checked="checked"<{/if}>/> 推荐</td>
            <td><div class="Validform_checktip">标题不能为空!</div></td>
        </tr>
        <tr>
            <td width="80">*信息名称：</td>
            <td width="320"><input type="text" value="<{$news.detail.news_name}>" id="name" name="name" class="inputxt"  datatype="*" nullmsg="请输入名称！"  /> <button name="tm" onClick="TS()" type="button">同标题</button></td>
            <td><div class="Validform_checktip">名称不能为空!</div></td>
        </tr>
        <tr>
            <td>*网址别名:</td>
            <td>
            <input type="text" value="<{$news.alias}>" id="alias" name="alias" class="inputxt" ajaxurl="<{spUrl c=news a=checkalias newsid=$news.news_id}>" datatype="*" errormsg="别名不能为空！" nullmsg="请输入网址别名！" />
             <button name="btzf" onClick="ZH()" type="button">名称转换</button>
            </td>
            <td><div class="Validform_checktip">网址别名,必须是英文字符!</div></td>
        </tr>
        <tr>
            <td>*关键字:</td>
            <td><input type="text" value="<{$news.detail.news_seokeywords}>" id="news_seokeywords" name="news_seokeywords" class="inputxt"/></td>
            <td><div class="Validform_checktip">多个关键字,英文豆号隔开</div></td>
        </tr>

        <tr>
            <td>*网页描述:</td>
            <td><input type="text" value="<{$news.detail.news_seodescription}>" id="news_seodescription" name="news_seodescription" class="inputxt"/></td>
            <td><div class="Validform_checktip">简要描述</div></td>
        </tr>
  
        <tr>
            <td>*描述：</td>
            <td colspan="2"><textarea name="content" id="content" rows="12" cols="80" style="width: 800px;"><{$news.detail.news_description}></textarea></td>
        </tr>
        <tr>
            <td>*关联:</td>
            <td><input type="text" value="<{$news.news_relate}>" id="news_Relate" name="news_Relate" class="inputxt"/> <a class='select_Relate'>选择关联</a></td>
            <td><div class="Validform_checktip">多个商品ID关联,英文豆号隔开</div></td>
        </tr>
        <tr>
            <td>*URL:</td>
            <td><input type="text" value="<{$news.detail.news_url}>" id="news_url" name="news_url" class="inputxt"/></td>
            <td><div class="Validform_checktip">跳转到</div></td>
        </tr> 
        <tr>
            <td>*排序:</td>
            <td><input type="text" value="<{$news.sort}>" id="sort" name="sort" class="inputxt"/></td>
            <td><div class="Validform_checktip">排序，大在前</div></td>
        </tr>
        <tr>
            <td>*主图：</td>
            <td><input type="hidden" name='allimg' id='allimg' value="<{$img}>"/>
            <select id="uploadList" name="uploadList" style="width:310px;" onChange="document.viewimg.src='<{$smarty.const.WEBDIR}>upload/'+options[selectedIndex].value">
            
            <option value="" selected="selected">选择并上传图片</option>
            <{foreach $allimg as $img2}>
            <option value="<{$img2}>" <{if $img2 eq $news.news_image}>selected="selected"<{/if}>><{$img2}></option>
            <{/foreach}> 
            
            
            </select></td>
            <td><textarea name="upimg" id="upimg" style="float:left;width: 25px;height:0px;"></textarea>
            <label><a href="#" onclick="document.getElementById('jtdiv').style.display='block';document.getElementById('jt').src='<{spUrl c=main a=jt}>&cropw=<{$smarty.const.NEWSIMGW}>&croph=<{$smarty.const.NEWSIMGH}>&pic=upload\/'+document.getElementById('uploadList').options[document.getElementById('uploadList').selectedIndex].value;">[ 切<{$smarty.const.NEWSIMGW}>-高<{$smarty.const.NEWSIMGH}>] </a></label>
            </td>
        </tr>
        <tr>
        <td></td>
        <td colspan="2" id="imglist"><img src="<{$smarty.const.WEBDIR}>upload/<{$news.news_image}>" onerror="this.src='<{$smarty.const.WEBDIR}>404/no.gif'" id="viewimg" name="viewimg" alt="选择你要显示的图片" height="100"/></td>
        </tr>


    </table>
    <div id="jtdiv" style="display: none;">
    <iframe  border=0 frameborder=0 framespacing=0 height='435' marginheight=0  marginwidth=0 name=jt id=jt scrolling=no 
 src="" width='100%' vspale="0"></iframe>
    </div>
    <br /><br />

<div id="submit_float">
<input type="hidden" name='action' id='action' value="<{$action}>"/>
                <input type="hidden" name='id' id='id' value="<{$news.news_id}>"/>
                <input class="newjh" type="submit" value="提 交" /> <input type="reset" value="重 置" />
                <input type="button" onclick="location.href='javascript:history.go(-1);'" value="返 回" /></div>
</form>

<script type="text/javascript">
        if($("#sort").val()==""){
        $("#sort").val('0');
        }
</script>
</body>

</html>